import { UserService } from '@/user/user.service';
import { Body, Controller, HttpCode, HttpStatus, Post, UsePipes } from '@nestjs/common';
import { AuthService } from './auth.service';
import { CreateUserDto } from './dto/register.dto';
import { LoginUserDato } from './dto/login.dto';
import { AuthPipe } from './pipe/auth.pipe';
import { ApiTags } from '@nestjs/swagger';

@Controller('auth')
@ApiTags('auth用户模块')
export class AuthController {
  constructor(
    private readonly authService: AuthService,
    private readonly userService: UserService
  ) {

  }

  @Post('login')
  @HttpCode(HttpStatus.OK)
  login(@Body() body: LoginUserDato) {
    return this.authService.signIn(body);
  }

  @Post('register')
  @UsePipes(new AuthPipe())
  register(@Body() body: CreateUserDto) {
    return this.userService.create(body);
  }

}
